package edu.sdufe.map.hashMap;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author wang'ji'cheng
 * @date 2025/7/26
 */
public class Demo1 {
    public static void main(String[] args) {
        HashMap<Student, String> student = new HashMap<>();

        Student s1 = new Student("张三", 23);
        Student s2 = new Student("李四", 24);
        Student s3 = new Student("张三", 23);

        student.put(s1,"上海");
        student.put(s2,"北京");
        student.put(s3,"山东");

        System.out.println(student);

        Set<Student> students = student.keySet();
        for (Student student1 : students) {
            System.out.println(student1+student.get(student1));
        }
        Set<Map.Entry<Student, String>> entries = student.entrySet();
        for (Map.Entry<Student, String> entry : entries) {
            System.out.println(entry);
        }

        entries.forEach(s-> System.out.println(s));
    }
}
